<%- include fheader.ejs%>
</br>
</br>
<style>
  .myborder {
    border:1px orange solid;
  }
  .mfb{
    width:200px;
    height: 20px;
  }
  .fileinput-button {
    position: relative;
    overflow: hidden;
    display: inline-block;
  }
  .fileinput-button input {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0;
    opacity: 0;
    -ms-filter: 'alpha(opacity=0)';
    font-size: 200px !important;
    direction: ltr;
    cursor: pointer;
  }

  /* Fixes for IE < 8 */
  @media screen\9 {
    .fileinput-button input {
      filter: alpha(opacity=0);
      font-size: 100%;
      height: 100%;
    }
  }
</style>

<div class="container">
  <div class="row">
    <div class="col-lg-4 col-md-4" style="padding-bottom: 2%;">
      <form>
      </form>
    </div>
    <div class="col-lg-12">
      <textarea class="form-control" placeholder='请输入UTC时间，如1460554600' rows="1" id="utc_sign"><%= serverutc%></textarea>
      <textarea class="form-control" placeholder='请输入JSON报文，测试签名' rows="3" id="req_sign"></textarea>
    </div>
  </div>
  </br>
  <div class="row">
    <div class="col-lg-12">
      <div style="background: lightskyblue;height: 120px;padding:10px;" id="res_sign">

      </div>
    </div>
  </div>
  </br>
  <div class="row">
    <div class="col-lg-12 col-md-12">
      <form action="" method="post" enctype="multipart/form-data">
        <span class="btn btn-success fileinput-button">
        <i class="glyphicon glyphicon-plus"></i>
        <span>Select files...</span>
        <!-- The file input field used as target for the file upload widget -->
        <input type="file" name="houseMaps" id="houseMaps"  multiple="true" onchange="FileSelected();" />
        </span>
        <!--input class="btn btn-danger" type="button" value="提交" style="width: 255px" onclick="AjaxFileUpload()"/-->
      </form>



      <div id="fileName"></div>
      <div id="fileSize"></div>
      <div id="fileType"></div>
      </br>
      <div class="progress myborder">
        <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60"
             aria-valuemin="0" aria-valuemax="100" id="uploadprogress" style="width: 0;">
        </div>
      </div>
      <div class="col-lg-12 col-md-12" id="result" ></div>
      </br>
      </br>
      <div class="col-lg-12 col-md-12" id="url"  style="background-color: lightskyblue"></div>
      </br>
    </div>
    </br>
    <div class="col-lg-6 col-md-6">
      <img id="rsimg" src="" width="300px" data-ss="<$= sss$>" height="200px"/>
    </div>
    <div class="col-lg-6 col-md-6" id="apkqr" style="height:200px;">

    </div>
  </div>
  </br>
  </br>
  <div class="row">
    <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
      <div style="background: lightskyblue;height: 200px;padding:10px;" >
      </div>
    </div>
  </div>
  </br>

</div>



<script>

  var SHA256 =  new Hashes.SHA256;
  var MD5 = new Hashes.MD5

  $('#req_sign').on('input',function(e){
    $("#res_sign").html('' +
        'MD5小写: </br>'+
        MD5.hex(('4e1OStRXpQprj87VOV7ugQsom8i'+this.value+$('#utc_sign').val()))+'</br>'+
        'MD5大写: </br>'+
        MD5.hex(('4e1OStRXpQprj87VOV7ugQsom8i'+this.value+$('#utc_sign').val())).toUpperCase()
    )
  });

  $('#utc_sign').on('input',function(e){
    $("#res_sign").html('' +
        'MD5小写: </br>'+
        MD5.hex(('4e1OStRXpQprj87VOV7ugQsom8i'+this.value+$('#utc_sign').val()))+'</br>'+
        'SHA256大写: </br>'+
        MD5.hex(('4e1OStRXpQprj87VOV7ugQsom8i'+this.value+$('#utc_sign').val())).toUpperCase()
    )
  });

  function FileSelected() {
    // document.getElementById('textfield').value=this.value
    var file = document.getElementById('houseMaps').files[0];
    if (file) {
      var fileSize = 0;
      if (file.size > 1024 * 1024)
        fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
      else
        fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';

      document.getElementById('fileName').innerHTML = '文件名称  ： ' + file.name;
      document.getElementById('fileSize').innerHTML = '文件大小  ： ' + fileSize;
      document.getElementById('fileType').innerHTML = '文件类型  ： ' + file.type;
    }
  }


  $('#houseMaps').fileupload({
    url: '/rest/svcWx/mdUploadCommonInnerTest',
    dataType: 'json',
    formData: {
      cellno: '138160255639',
      insure_id:10001212,
      imgtype:'comp_bodyface',//comp_cellface,comp_bodyface
      udid:'vsdfadfadfadf1'
    },
    done: function (e, data) {
      $("#result").text(JSON.stringify(data.result))
      if(data.result.info.result==='success'){
        $('#apkqr').html('').qrcode({width: 200,height: 200,text:data.result.info.fname} );
        $("#rsimg").attr('src',data.result.info.fname)
        $("#url").text(data.result.info.fname)
      }
    },
    progressall: function (e, data) {
      var progval = parseInt(data.loaded / data.total * 100, 10);
      console.log(progval)
      $('#uploadprogress').css('width',progval+'%')
    }
  })

  var data={
    name:"jeakey",
    word:"hi~",
    friend:[
      "hahn",
      "fay"
    ]
  }

  var data={
    name:"jeakey",
    word:"hi~",
    friend:[
      "hahn",
      "fay"
    ]
  }

  /*

  */

</script>
<%- include ftailer.ejs%>